package com.scuec.demo.mapper;

import com.scuec.demo.entity.StudentInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
//http://localhost:8080/stu/list
public interface StudentMapper {
    @Select("select * from student_info")
    public List<StudentInfo> getStudentInfo();

    @Select("select * from student_info where stuid=#{id}")
     StudentInfo getStudentInfoById(Integer id);

    @Delete("delete from student_info where stuid=#{id}")
    public int  deleteStudentInfoById(Integer id);

    @Update("update student_info set stu_name=#{stu_name}, stu_sex=#{stu_sex}, stu_phone=#{stu_phone}, stu_birthday=#{stu_birthday}, \n" +
            "stu_education=#{stu_education}, stu_interest=#{stu_interest} where stuid= #{stuid}")
    int updateStudentInfo(@RequestBody StudentInfo studentInfo);


    @Insert("insert into student_info (stu_no,stu_name,stu_sex,stu_birthday,stu_education,stu_interest,my_color,create_date,clsid) \n" +
            "values(#{stu_no},#{stu_name},#{stu_sex},#{stu_birthday},#{stu_education},#{stu_interest}, #{my_color},sysdate(),#{clsid})")
    int insertStudentInfo(StudentInfo studentInfo);



}